home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.uvm.abt.edit;
-
- import java.awt.Component;
- import java.awt.Font;
- import java.beans.PropertyEditorSupport;
- import java.util.ResourceBundle;
-
- public class FontEditor extends PropertyEditorSupport {
- private static ResourceBundle resabtedit = ResourceBundle.getBundle("com/ibm/uvm/abt/edit/abtedit");
- FontPropertyEditor customEditor = null;
-
- public String getAsText() {
- Font font = (Font)this.getValue();
- String strStyle;
- if (font.isBold()) {
- strStyle = font.isItalic() ? resabtedit.getString("bolditalic") : resabtedit.getString("bold");
- } else {
- strStyle = font.isItalic() ? resabtedit.getString("italic") : resabtedit.getString("plain");
- }
-
- return font.getName() + ", " + strStyle + ", " + font.getSize();
- }
-
- public Component getCustomEditor() {
- if (this.customEditor == null) {
- Font aFont = (Font)this.getValue();
- if (aFont == null) {
- this.customEditor = new FontPropertyEditor();
- } else {
- this.customEditor = new FontPropertyEditor(aFont);
- }
- }
-
- return this.customEditor;
- }
-
- public String getJavaInitializationString() {
- Font font = (Font)this.getValue();
- return "new java.awt.Font(\"" + font.getFamily() + "\", " + font.getStyle() + ", " + font.getSize() + ")";
- }
-
- public Object getValue() {
- return this.customEditor != null ? this.customEditor.getFontValue() : super.getValue();
- }
-
- public void setAsText(String text) throws IllegalArgumentException {
- throw new IllegalArgumentException(text);
- }
-
- public void setValue(Object newValue) {
- super.setValue(newValue);
- if (this.customEditor != null) {
- this.customEditor.setFontValue((Font)newValue);
- }
-
- }
-
- public boolean supportsCustomEditor() {
- return true;
- }
- }
-